﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ContactCenter.Core.Interfaces;
using NHibernate;
using ContactCenter.Core.DomainModel;

namespace ContactCenter.Persistence.NH
{
    public class CustomerRepository : ICustomerRepository
    {
        private readonly ISession _session;

        public CustomerRepository(ISession session)
        {
            this._session = session;
        }
        
        public IEnumerable<Customer> GetAll()
        {
            return _session.CreateQuery("from Customer").List<Customer>();
        }

        public void Save(Customer customer)
        {
            _session.Save(customer);
        }

        public Customer GetById(int customerId)
        {
            return _session.Get<Customer>(customerId);
        }
    }
}
